home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-20 | 2.6 KB | 142 lines | [TEXT/CWIE] |
- /*
- File: LProgressDialog.cp
-
- Contains: Progress bar dialog for PowerPlant.
- An LProgressIndicatorProxy subclass.
-
- Version: 2.1
-
- Author: Chris K. Thomas, ckt@best.com
-
- Copyright: ©1996 Chris K. Thomas. All Rights Reserved.
- */
-
- //
- // includes
- //
-
- #include <UReanimator.h>
- #include <LDialogBox.h>
- #include <LCaption.h>
-
- #include "LThermometerPane.h"
- #include "LProgressDialog.h"
-
- //
- // const
- //
-
- const UInt16 kProgressDialogID = 1024; // id of our ‘PPob’
-
- const PaneIDT kFirstCaptionID = 'cap1'; // “Now doing something”
- const PaneIDT kSecondCaptionID = 'cap2'; // “File "martha washington"”
- const PaneIDT kThirdCaptionID = 'capO'; // “40 of 300”
- const PaneIDT kThermometerPaneID = 'prog'; // the star attraction
-
- //
- // • Construct
- //
- LProgressDialog::LProgressDialog(Str255 inActivity, LCommander *inSuperCommander)
- {
- //
- // setup command chain
- //
-
- LCommander::SetDefaultCommander(inSuperCommander);
-
- //
- // load our dialogbox
- //
-
- mDialog = reinterpret_cast<LDialogBox *>(UReanimator::ReadObjects('PPob', kProgressDialogID));
- ThrowIfNULL_(mDialog);
-
- mDialog->SetSuperCommander(this);
- LCommander::SwitchTarget(mDialog);
-
- mDialog->SetDescriptor(inActivity);
- mDialog->FinishCreate();
-
- mStopClicked = false;
-
- //
- // get pointers to all our panes
- //
-
- mCaptionOne = dynamic_cast<LCaption *>(mDialog->FindPaneByID( kFirstCaptionID ));
- mCaptionTwo = dynamic_cast<LCaption *>(mDialog->FindPaneByID( kSecondCaptionID ));
- mCaptionThree = dynamic_cast<LCaption *>(mDialog->FindPaneByID( kThirdCaptionID ));
-
- mProgressBar = dynamic_cast<LThermometerPane *>(mDialog->FindPaneByID( kThermometerPaneID ));
-
- Assert_(mCaptionOne);
- Assert_(mCaptionTwo);
- Assert_(mCaptionThree);
- Assert_(mProgressBar);
-
- //
- // setup sundry state
- //
-
- SetProxyTarget(mProgressBar);
-
- mCaptionOne->Draw(NULL);
- // mDialog->Draw(NULL);
- }
-
- LProgressDialog::~LProgressDialog()
- {
- if(mDialog)
- delete mDialog;
- }
-
- //
- // • Caption accessors
- //
- void
- LProgressDialog::SetActionDescriptor(Str255 inAction)
- {
- mCaptionOne->SetDescriptor(inAction);
- }
-
- void
- LProgressDialog::SetStepDescriptor(Str255 inAction)
- {
- mCaptionTwo->SetDescriptor(inAction);
- }
-
- void
- LProgressDialog::SetCountDescriptor(Str255 inAction)
- {
- mCaptionThree->SetDescriptor(inAction);
- }
-
-
- //
- // • Command handling (listening for Stop button)
- //
- Boolean
- LProgressDialog::ObeyCommand(
- CommandT inCommand,
- void *ioParam )
- {
- Boolean cmdHandled = true;
-
- switch ( inCommand )
- {
- case -1:
- SetStopClicked(true);
- break;
-
- default:
- {
- // Call inherited.
- cmdHandled = LCommander::ObeyCommand( inCommand, ioParam );
- }
- break;
-
- }
-
- return cmdHandled;
- }
-